package cn.shutdown.service.impl;

import cn.shutdown.dao.IPostDao;
import cn.shutdown.po.Post;
import cn.shutdown.service.IPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Created by wejack on 2016/9/25.
 */
@Service
public class PostServiceImpl implements IPostService {

    @Autowired
    private IPostDao postDao;

    public List<Map<String, Object>> findByCategoryId(int categoryId) {
        return postDao.selectByCategoryId(categoryId);
    }

    public Map<String, Object> findById(int id) {
        return postDao.selectById(id);
    }

    public void save(Post post) {
        postDao.insert(post);
    }

    public int getMaxPostLevel(int id) {
        return postDao.selectMaxLevel(id);
    }

    public List<Map<String, Object>> findSubPost(int id) {
        return postDao.selectSubPost(id);
    }

    public List<Map<String, Object>> getPostListByCategoryId(int categoryId) {
        return postDao.selectByCategoryIdNoLimit(categoryId);
    }

}
